<!DOCTYPE html>
<html xmlns:layout="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
	layout:decorate="~{common/layout}">

<head>
	<meta charset="UTF-8">
	<title>血糖记录管理系统</title>
	<style scoped lang="less">

	</style>
</head>

<body>
	<div layout:fragment="fragment_body">
		<van-row>
			<van-nav-bar
			  title="分享记录"
			  left-text="返回"
			  left-arrow
			  @click-left="onClickLeft"
			/>
		</van-row>
		<van-row>
			<van-empty v-if="shares == null || shares.length == 0" description="暂无发布分享" ></van-empty>
			<van-card
			  :desc="share.account.accountNick"
			  :title="share.shareTitle"
			  v-for="(share, index) in shares" :key="index">
			    <template #num>
					<van-button size="mini" plain type="danger" @click="delCilck(share.shareId)">删除</van-button>
				</template>
				<template #thumb>
					<van-image contain round width="2.5rem" height="2.5rem" :src="share.account.accountLogo" />
				</template>
				<template #price>
					{{share.shareTime}}
				</template>
			  </van-card>
		</van-row>
	</div>
</body>
<script type="text/javascript" layout:fragment="fragment_script">
	let vueData = {
		activeMenu: 'my',
		shares: []
	}
	let vueComputed = {

	}
	let vueMethods = {
		onClickLeft(){
			window.location.href='/user/my'
		},
		getShares() {
			let that = this
			console.log(that.accountInfo)
			postRequst('/user/getShares', {accountId: that.accountInfo.accountId}, true).then(function (resp) {
				that.shares = resp.rows
			})
		},
		delCilck(shareId) {
			let that = this
			postRequst('/user/delShare', {shareId: shareId}, true).then(function (resp) {
				if(resp.status === 0){
					that.getShares()
					that.$toast.success(resp.msg);
				}else{
					that.$toast(resp.msg);
				}
			})
		},
	}
	function vueCreated() {
		let that = this
		setTimeout(function(){
			that.getShares()
		}, 100)
	}
</script>

</html>